/**
 * VYPe11 Project
 * VYPe11 language compiler.
 * Authors: Jozef Lang (xlangj01), 
 * 			Zoltan Zemko (xzemko01)
 * 2011
 */
package cz.vutbr.fit.VYPe.team18.VYPe11.nodes.function;

import java.io.IOException;

import cz.vutbr.fit.VYPe.team18.VYPe11.nodes.GlobalItemNode;
import cz.vutbr.fit.VYPe.team18.VYPe11.nodes.IdentifierNode;
import cz.vutbr.fit.VYPe.team18.VYPe11.nodes.data_type.DataTypeNode;
import cz.vutbr.fit.VYPe.team18.VYPe11.nodes.statement.StatementListNode;

public class FunctionDefinitionNode extends GlobalItemNode {
	private DataTypeNode returnType;
	private IdentifierNode id;
	private ParameterListNode parameterList;
	private StatementListNode statements;
	
	public FunctionDefinitionNode(DataTypeNode type,
									IdentifierNode id,
									ParameterListNode parameterList,
									StatementListNode statements) {
		this.returnType=type;
		this.id=id;
		this.parameterList=parameterList;
		this.statements=statements;
	}

	public DataTypeNode getReturnType() {
		return returnType;
	}

	public IdentifierNode getId() {
		return id;
	}

	public ParameterListNode getParameterList() {
		return parameterList;
	}

	public StatementListNode getStatements() {
		return statements;
	}

	@Override
	public void generateTAC() throws IOException {
		writeTAC("function", this.getId().getId(),"", "");
		writeTAC("begin_function", "","", "");
		parameterList.generateTAC();
		statements.generateTAC();
		writeTAC("end_function", "","", "");
	}	
}
